var e = getApp(), n = (require("../../utils/function.js"), require("../../data/mockData.js"), 
require("../../api.js"));

Page({
    data: {
        names: "",
        phones: "",
        type: !1
    },
    onLoad: function(e) {},
    agreement_hover: function() {
        var e = this.data.type;
        e = !e, this.setData({
            type: e
        });
    },
    agreements: function() {
        wx.navigateTo({
            url: "../agreements/index"
        });
    },
    formSubmit: function(t) {
        var o = this.data.type;
        if (!t.detail.value.names) return wx.showToast({
            title: "姓名不能为空！",
            icon: "none",
            duration: 2e3
        }), !1;
        if (!t.detail.value.shop_name) return wx.showToast({
            title: "商铺名称不能为空！",
            icon: "none",
            duration: 2e3
        }), !1;
        if (0 == t.detail.value.phones.length) return wx.showToast({
            title: "手机号码不能为空",
            icon: "none",
            duration: 2e3
        }), !1;
        if (t.detail.value.phones.length < 11) return wx.showToast({
            title: "手机号码长度不够",
            icon: "none",
            duration: 2e3
        }), !1;
        if (!o) return wx.showToast({
            title: "请阅读选择申请协议！",
            icon: "none",
            duration: 2e3
        }), !1;
        var a = {
            truename: t.detail.value.names,
            phone: t.detail.value.phones,
            shop_name: t.detail.value.shop_name
        };
        e.request({
            url: n.user.apply_distribution,
            method: "post",
            data: a,
            success: function(e) {
                console.log(e.code), 1 == e.code ? (wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 2e3
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 2e3)) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 2e3
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});